package 云老板代码;

import java.sql.SQLException;
import java.util.List;

public class Test {

	/**
	 * @param args
	 */
	//添加数据
	public static void main(String[] args) throws SQLException {
		Student s=new Student();
	    s.setStuId("900");
		s.setStuName("欧阳锋");
		s.setStuSex("男");
		s.setStuAge(63);
		StudentDAO dao=new StudentDAO();
		try {
			dao.add(s);
		}catch (SQLException e){
			e.printStackTrace();
		}

		//删除数据
	  try {
			dao.delete("004");
	   } catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	  //修改数据
		try {
			s=dao.findById("003");
			s.setStuName("黄蓉");
			s.setStuSex("女");
			dao.edit(s);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//查询数据
		try{
			List<Student> list=dao.findByProperty("stuAge",20);
			for (Student s1: list){
				System.out.print(s1.getStuId()+"\t");
				System.out.print(s1.getStuName()+"\t");
				System.out.print(s1.getStuSex()+"\t");
				System.out.print(s1.getStuAge()+"\t");
			}
		} catch (SQLException throwables) {
			throwables.printStackTrace();
		}

		SqlHelper.closeConn();
	}

}

